package jokode

func Debug(args ...any) {
	Logger().Debug(args...)
}

func Info(args ...any) {
	Logger().Info(args...)
}

func Warn(args ...any) {
	Logger().Warn(args...)
}

func Error(args ...any) {
	Logger().Error(args...)
}

func Fatal(args ...any) {
	Logger().Fatal(args...)
}

func Debugf(format string, args ...any) {
	Logger().Debugf(format, args...)
}

func Infof(format string, args ...any) {
	Logger().Infof(format, args...)
}

func Warnf(format string, args ...any) {
	Logger().Warnf(format, args...)
}

func Errorf(format string, args ...any) {
	Logger().Errorf(format, args...)
}

func Fatalf(format string, args ...any) {
	Logger().Fatalf(format, args...)
}

func LogSync() error {
	return Logger().Sync()
}

func Logger() JoLogger {
	return getLoggerInstance()
}

func RegLogProvider(provider LogProvider) {
	regLogProviderImpl(provider)
}

func InitLogger(logFileName string, withConsole bool) error {
	logCfg := NewLogConfig()
	logCfg.FileName = logFileName
	logCfg.OutToStdIo = withConsole

	return InitLoggerConfig(logCfg)
}

func InitLoggerConfig(logCfg *LogConfig) error {
	return initLoggerConfigImpl(logCfg)
}

type LogProvider interface {
	GetName() string
	InitLogger(cfg *LogConfig) (JoLogger, error)
	GetLogger() JoLogger
}
